<template>
  <div class="login-content">
    <van-nav-bar title="意见反馈" left-arrow @click-left="onClickLeft" />
    <van-row>
      <van-col span="24">
        <van-form @submit="onSubmit">
          <van-field
            v-model="message"
            rows="6"
            autosize
            label
            type="textarea"
            maxlength="300"
            name="advise"
            placeholder="请输入意见"
            :rules="[{ required: true, message: '请输入您的意见' }]"
            show-word-limit
          />
          <div style="margin: 16px;">
            <van-button round block type="info" native-type="submit">提交</van-button>
          </div>
        </van-form>
      </van-col>
    </van-row>
  </div>
</template>
<script>
import { Toast } from "vant";
import {feedBack} from "@/api/personal/personal";
export default {
  data() {
    return {
      message: ""
    };
  },
  methods: {
    // 提交意见
    onSubmit(values) {
      let userData = this.$session.get("user"); //获取session
      let condition = {
        opinion: values.advise, //  意见内容
        createUser: JSON.parse(userData).name //反馈人名称
      };
      feedBack(condition, data => {
        data.success===true? Toast(data.info):Toast(data.info);
        this.message="";
      });
     
    },
    // 返回事件
    onClickLeft() {
      this.$router.go(-1);
    }
  },
};
</script>
<style lang="scss" scoped>
.login-content {
  .login-header {
    height: 60px;
    width: 100%;
    color: white;
    line-height: 60px;
    background-color: #1989fa;
    .van-nav-bar .van-icon {
      color: white;
    }
  }
}
</style>